package com.peas.platform.module.icims;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.LoggerContext;
import com.peas.platform.common.core.utils.MultipartFileUtil;
import com.peas.platform.module.icims.base.sys.api.resp.InvoiceResp;
import com.peas.platform.module.icims.base.sys.component.InvoiceExtractor;
import org.junit.Test;
import org.slf4j.LoggerFactory;

import java.io.File;

public class InvoiceExtractorTestCase {

    private final InvoiceExtractor invoiceExtractor = new InvoiceExtractor();

    @Test
    public void extractFile() {
        String path1 = "/Users/caizhaohui/IdeaProjects/icims/data/顺丰电子发票1116.pdf";
        String path2 = "/Users/caizhaohui/IdeaProjects/icims/data/发票2.pdf";
        LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
        Logger logger = loggerContext.getLogger("ROOT");
        logger.setLevel(Level.OFF);
        InvoiceResp v1 = invoiceExtractor.extract(MultipartFileUtil.fileToCommonsMultipartFile(new File(path1)));
        System.out.println("================================================================================================");
        InvoiceResp v2 = invoiceExtractor.extract(MultipartFileUtil.fileToCommonsMultipartFile(new File(path2)));
        System.out.println("================================================================================================");
        System.out.println(v1);
        System.out.println(v2);
    }

    @Test
    public void extractPath() {
        String path1 = "/Users/caizhaohui/IdeaProjects/icims/data/顺丰电子发票1116.pdf";
        String path2 = "/Users/caizhaohui/IdeaProjects/icims/data/发票2.pdf";
        LoggerContext loggerContext = (LoggerContext) LoggerFactory.getILoggerFactory();
        Logger logger = loggerContext.getLogger("ROOT");
        logger.setLevel(Level.OFF);
        System.out.println(invoiceExtractor.extract(path1));
        System.out.println("================================================================================================");
        System.out.println(invoiceExtractor.extract(path2));
        System.out.println("================================================================================================");
    }

}
